﻿#region Imports
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using Jounce.Core.ViewModel;
#endregion

namespace JounceSilverlightDemo.ViewModels
{
    [ExportAsViewModel("HeaderVM")]
    public class HeaderViewModel : BaseViewModel, IPartImportsSatisfiedNotification
    {
        #region Declarations
        public const string defaultUser = "< Guest >";
        #endregion

        #region Properties
        private string userName = defaultUser;
        public string UserName
        {
            get { return userName; }
            set { userName = !String.IsNullOrEmpty(value) ? value : defaultUser; RaisePropertyChanged("UserName"); }
        }
        #endregion

        #region Core methods
        public void OnImportsSatisfied()
        {
            ;
        }

        protected override void InitializeVm()
        {
            base.InitializeVm();
        }

        protected override void ActivateView(string viewName, IDictionary<string, object> viewParameters)
        {
            object userName = "";
            if (viewParameters.ContainsKey("UserName"))
            {
                viewParameters.TryGetValue("UserName", out  userName);
                UserName = Convert.ToString(userName);
            }
        }
        #endregion
    }
}
